<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
	<head>
	 <%@ include file="/WEB-INF/views/common/import.jsp"%>
		<title>Hiring-求职者后台</title>
		 <style>
	    	.resume {
	    		font-weight: bolder;
	    		font-size: 20px;
	    		margin-right: 10px;
	    	}
	    </style>
	</head>
	<body>
	<div class="container">
	<h3>登录成功!欢迎您 <small>
		<span class="label label-success">${talent.name}</span>
			</small>
			<a href="<%=request.getContextPath()%>/TalentServlet?command=logout">
			<span class="pull-right"><button class="btn btn-warning">注销</button></span>
			</a>
			<span class="pull-right">&nbsp;</span>
			<a href="<%=request.getContextPath()%>/TalentServlet?command=toDatePwdUI">
			<span class="pull-right"><button class="btn btn-warning">修改密码</button></span>
			</a>
			<span class="pull-right">&nbsp;</span>
			<a href="<%=request.getContextPath()%>/TalentServlet?command=toUpdateUser">
			<span class="pull-right"><button class="btn btn-warning" >个人信息</button></span>
			</a>
			<span class="pull-right">&nbsp;</span>
    		<a href="<%=request.getContextPath()%>/CommonServlet?command=toMainUI">
    		<button type="button" class="btn btn-warning pull-right">返回首页</button>
    		</a>
			</h3>
			<hr>
	    	<span class="resume">简历管理</span>
	    	<a href="<%=request.getContextPath()%>/ResumeServlet?command=toAdd">添加简历</a>
	    	<table class="table">
		      <thead>
		        <tr>
		          <th>序号</th>
		          <th>求职意向</th>
		          <th>工作经历</th>
		          <th>项目经验</th>
		          <th>操作</th>
		        </tr>
		      </thead>
		      <tbody>
		      <c:forEach items="${pageModel.list}" var="listResume" varStatus="v">
		        <tr>
		          <td>${v.count }</td>
		          <td>${listResume.intention }</td>
		          <td>${listResume.workExperience }</td>
		          <td>${listResume.projectExperience }</td>
		          <td><a href="<%=request.getContextPath()%>/ResumeServlet?command=toUpdate&id=${listResume.id }">修改</a> <a href="javascript:void(0)"onclick="del(this,${listResume.id })">删除</a>
		        </tr>
		        </c:forEach>
		      </tbody>
		    </table>
		    <div class="pull-right">
		        	<button type="button" class="btn btn-default" onclick="location='<%=request.getContextPath()%>/ResumeServlet?command=list&pageNo=${pageModel.first }&pageSize=10'" <c:if test="${pageModel.pageNo == pageModel.first }">disabled="disabled"</c:if>>首页</button>
		        	<button type="button" class="btn btn-default" onclick="location='<%=request.getContextPath()%>/ResumeServlet?command=list&pageNo=${pageModel.pre }&pageSize=10'" <c:if test="${pageModel.pageNo == pageModel.first }">disabled="disabled"</c:if>>上一页</button>
		        	<select onchange="go(this)" class="select">
		        		<script>
		        			var totalPage = '${pageModel.totalPage }';
		        			var pageNo = '${pageModel.pageNo}'
		        			for (var i = 1; i <= totalPage; i++) {
		        				if (i == pageNo) {
		        				   document.write('<option value="'+ i +'" selected>第' + i +'页</option>');
		        				} else {
		        				   document.write('<option value="'+ i +'">第' + i +'页</option>');	
		        				}
		        			}
		        		</script>
		        	</select>
		        	<button type="button" class="btn btn-default" onclick="location='<%=request.getContextPath()%>/ResumeServlet?command=list&pageNo=${pageModel.next }&pageSize=10'" <c:if test="${pageModel.pageNo == pageModel.last }">disabled="disabled"</c:if>>下一页</button>
		        	<button type="button" class="btn btn-default" onclick="location='<%=request.getContextPath()%>/ResumeServlet?command=list&pageNo=${pageModel.last }&pageSize=10'" <c:if test="${pageModel.pageNo == pageModel.last }">disabled="disabled"</c:if>>尾页</button>
		        	&nbsp;&nbsp;&nbsp;&nbsp;
		        	<c:if test="${((pageModel.pageNo - 1) * pageModel.pageSize + pageModel.pageSize)< pageModel.totalRecords}">
		        	当前第${pageModel.pageNo }页，
		        	显示${(pageModel.pageNo - 1) * pageModel.pageSize + 1}到第${(pageModel.pageNo - 1) * pageModel.pageSize + pageModel.pageSize}，共${pageModel.totalPage }页
		        	</c:if>
		        	
		        	<c:if test="${((pageModel.pageNo - 1) * pageModel.pageSize + pageModel.pageSize)> pageModel.totalRecords}">
		        	当前第${pageModel.pageNo }页，
		        	显示${(pageModel.pageNo - 1) * pageModel.pageSize + 1}到第${pageModel.totalRecords}，共${pageModel.totalPage }页
		        	</c:if>
		        </div>
    	
    	<script>
    		/**
    		 * 指定跳转到第几页
    		 */
    		function go(obj) {
    			location='<%=request.getContextPath()%>/ResumeServlet?command=list&pageNo=' + obj.value+'&pageSize=10';
    		}
    		function del(obj,listResumeId){
    			$.get('<%=request.getContextPath()%>/ResumeServlet?command=delete&resumeId=' + listResumeId + '&time=' + new Date().getTime(), function(text){
   			     // 如果是成功了就在页面上删除当前a标签所在的tr，如果不成功给出提示
   			     if (text == 'fail') {
   			    	layer.msg('操作失败！', {time: 2000, icon: 5});
   			     } else {
   			    	layer.msg('操作成功！', {time: 2000, icon: 6});
   			    	$(obj.parentNode.parentNode).remove();
   			     }
       		  });
    		}
    	</script>
		    <span class="resume">应聘信息</span>
	    	<table class="table">
		      <thead>
		        <tr>
		          <th>序号</th>
		          <th>求职公司</th>
		          <th>求职职位</th>
		          <th>申请时间</th>
		          <th>当前状态</th>
		          <th>操作</th>
		        </tr>
		      </thead>
		      <tbody>
		     <c:forEach items="${listapplication }" var="listapp" varStatus="v">
		      	<tr>
		          <td>${v.count }</td>
		          <td>${listapp.company$name }</td>
		          <td>${listapp.position$name }</td>
		          <td><fmt:formatDate value="${listapp.appTime }"  type="both" /></td>
		          <td>${listapp.statusStr }</td>
		          <td><a href="javascript:void(0)"onclick="delApp(this,${listapp.id })">删除</a></td>
		        </tr>
		       </c:forEach>
		      </tbody>
		    </table>
    	</div>
    	<script>
    	function delApp(obj,listAppId){
			$.get('<%=request.getContextPath()%>/ResumeServlet?command=deleteApp&listAppId=' + listAppId + '&time=' + new Date().getTime(), function(text){
			     // 如果是成功了就在页面上删除当前a标签所在的tr，如果不成功给出提示
			     if (text == 'fail') {
			    	layer.msg('操作失败！', {time: 2000, icon: 5});
			     } else {
			    	layer.msg('操作成功！', {time: 2000, icon: 6});
			    	$(obj.parentNode.parentNode).remove();
			     }
   		  });
		}
    	</script>
		<script src="<%=request.getContextPath() %>/static/common/vendor/jquery.min.js"></script>
		<script src="<%=request.getContextPath() %>/static/common/vendor/bootstrap/js/bootstrap.min.js"></script>
	</body>
</html>